home *** CD-ROM | disk | FTP | other *** search
/ Experimental BBS Explossion 3 / Experimental BBS Explossion III.iso / c / xlib20b.zip / EXAMPLE3.C < prev    next >
C/C++ Source or Header  |  1993-08-19  |  1KB  |  51 lines

  1. /* The following Microsoft C 7.0 program should be linked with the assembly
  2. language library in Example 2.  Combine the library with XLIB.LIB using the
  3. Microsoft Lib utility.  The C program first initializes XLIB.  Next, it
  4. creates a float array.  A control block for SUMARRAY is then constructed
  5. and the call to SUMARRAY is executed.  Finally, the condition code in the
  6. control block is inspected and results are printed. */
  7.  
  8. #include <stdio.h>
  9. #include <xlib.h>
  10.  
  11. extern long __far __pascal LINADR(void __far *ptr);
  12. extern void __far __pascal SUMARRAY(void __far *ptr);
  13.  
  14. struct arraydata
  15. {
  16.   long condcode;
  17.   long n;
  18.   long address;
  19.   float sum;
  20. } ad;
  21.  
  22. float a[101];
  23.  
  24. main()
  25. {
  26.   int i;
  27.   long temp;
  28.  
  29.   temp = INITXLIB();
  30.   if (temp != 0)
  31.   {
  32.     printf("Initialization Error:  %lX\n",temp);
  33.     return 0;
  34.   }
  35.  
  36.   for(i = 0; i <= 100; i++)
  37.     a[i] = i;
  38.  
  39.   ad.condcode = 0;
  40.   ad.n = 50;
  41.   ad.address = LINADR(a);
  42.  
  43.   SUMARRAY(&ad);
  44.   if (ad.condcode != 0)
  45.   {
  46.     printf("Error:  %lX\n",ad.condcode);
  47.     return 0;
  48.   }
  49.   printf("Sum:  %f\n",ad.sum);
  50. }
  51.